function chars_loading()
{	var HTMLOut = document.getElementById("outDiv").innerHTML;

	HTMLOut += "chars loading!" + "<br>";
	document.getElementById('outDiv').innerHTML = HTMLOut;
	
	document.getElementById('textIn').focus();
}

var Char = new Object;
var NUM_CHAR = 0;

function makeChar(name,pname,firstplace,description,talks,subjects,reactions,presents,mannerisms)
{

	Char[NUM_CHAR] = new Object;
	Char[NUM_CHAR].id = NUM_CHAR;
	Char[NUM_CHAR].name = name; // short version of name
	Char[NUM_CHAR].pname = pname; // proper name
    Char[NUM_CHAR].firstplace = firstplace; // initial location
	Char[NUM_CHAR].description = description;
	Char[NUM_CHAR].talks = talks; // default talks
	Char[NUM_CHAR].subjects = subjects; // talks about specific tokens
	Char[NUM_CHAR].reactions = reactions;
	Char[NUM_CHAR].presents = presents; // reactions to certain Things

	eval(name + " = Char[" + NUM_CHAR + "];");

        NUM_CHAR++;
}

makeChar("newsvendor", "the newspaper vendor", intersection,
	"His trenchcoat and sweater do a poor job of hiding his disgusting \
paunch. His sweaty pink fingers encase a steaming cup of coffee that he \
continually refreshes from a thermos. Likely a recovering alcoholic.",
	"[[talk_bernard()]]",
	"sugar::\"You hearda this sugar nonsense? 'Parently New York's not gettin' \
any sugar supplied at the moment. Some kinna union thing. Can you believe that? \
Only a coupla papers covered it, but us newsvendors don't miss anything. We see \
every headline, no matter how small the type. 'Course, if Russia nukes us \
tomorrow, sugar won't be the worst of our problems. Inna final analysis.\"\
/coffee|thermos|mug|cup::\"I like two sugars, but no one in the city's sellin' sugar these days!\"\
/boy::\"When's he gonna pay for those funny books anyway?\"\
/newspaper|paper::\"If your papers show up, I'll hold one for you.\"\
/russia|union|unions|nukes|bombs|war|analysis::\"Some things you can't change, no matter how much you know.\"\
/unknown::\"I dunno about that, so it can't be worth knowin'.\"",
"",
"",
""
);
function talk_bernard()
{
    switch( talkindex(newsvendor) )
    {
    case 0:
        set_talkindex(newsvendor, 1);
        say( "\"I hafta disappoint you. I always keep your copy ready, but the New Frontiersman never showed up this morning. Not that I'm surprised. I'm a newsvendor! We see a lotta papers come and go, and I never thought the New Frontiersman had stayin' power. I always said they shoulda been outta business a long time ago. 'Course, that's just my opinion.\"" );
        break;
    case 1:
        say( "He gulps his coffee and grimaces. \"Ugh, someone oughtta do something.  What, you still here?  If your papers show up, I'll hold one for you.\"" );
        break;
    }
}

makeChar("boy", "a loitering teenager", intersection,
"A typical modern youth, idling his time away with mindless entertainment.",
"He's too engrossed in his comic book to speak to you.",
"",
"",
"",
""
);

makeChar("joey", "a taxi", nowhere,
"It's a taxicab, waiting for customers.",
"\"Want a ride?\"",
"ride|rockefeller::\"You don't look like you could afford it. No offense.\"\
/customers::\"See any around here?\"\
/porn|pornography|playboy::The driver blushes, then frowns at you. \"Yeah, I read that stuff. So? Gotta point, or are you just being a pervert?\"\
/unknown::\"Hey, I'm a cab driver, not an advice column.\"",
"",
"",
""
);

makeChar(
// name, proper name, initial location:
"dan", "Daniel", danshouse2,
// description:
"[[x_dan()]]",
// generic talks:
"[[talkDan('')]]",
// subjects:
"handcuffs|cuffs|bondage|undergarments|underwear|panties::\"I was-- look, please don't ask. I was lonely, okay?\"\
/dan::[[talkDan('self')]]\
/key::[[talkDan('key')]]\
/sugar::[[talkDan('sugar')]]\
/adrian::[[talkDan('adrian')]]\
/laurie::[[talkDan('laurie')]]\
/grappling_gun::[[talkDan('gun')]]\
/archie::[[talkDan('archie')]]\
/leslie::[[talkDan('leslie')]]\
/unknown::\"Sorry Rorschach, I don't know anything about that.\"",
// reactions:
"",
// presents:
"grappling_gun::[[giveDanGun()]]",
// mannerisms:
""
);
function x_dan()
{
    if (gs("danfree") == 0) {
        return( "Daniel is bound to his bedframe with a pair of fuzzy pink handcuffs, dressed only in female undergarments. You've always known he has deviant appetites, but it's still disappointing to find him like this." );
    }
    return( "Your former partner's crimefighting identity was Nite Owl II. He has gained some weight since his retirement, but he retains the same hopeful, anxious demeanor." );
}
function talkDan(x) {
    if (x == "") {    
        switch( talkindex(dan) )
        {
            case 0:
                set_talkindex(dan, 1);
                say( "\"Rorschach, can you help me out here?\"" );
                break;
            case 1:
                set_talkindex(dan, 2);
                say( "\"I know this looks pretty bad, but...you're not going to leave me here, right?\"" );
                break;
            case 2:
                say( "\"Come on, please, I have to go to the bathroom!\"" );
                break;
            case 3:
                say("\"Just...give me a minute, okay? Stop looking at me like that.\"");
                break;
            case 4:
                if (!is_in_inv(handwritten_book))
                    say("\"It shouldn't take me too long to fix this...come back in a little while, okay?\"");
                else {
                    set_talkindex(dan, 99);
                    say("\"Hey, I've got the grappling gun working again. It should have a longer range now too, I re-tooled the rifling, and there's a new coat of sealant around the compression chamber, I know it used to get a little finicky in the rain...anyway, here you go!\""
                    add_to_inv(grappling_gun);
                }
                break;
            default:
                // put random stuff here!
                say("\"Uh...hi Rorschach. Want me to heat up some beans?\"");
        }
        return;
    }

//I know it could get a little finicky in the rain, but I put a little extra sealant around the compression chamber so it all stays dry, and I re-cut the rifling, it was getting a little
    if (gs("danfree") == 0) {
        switch (x) {
            case "self":
                say("\"I'm not hurt, I'm just...aw hell Rorschach, can't you do something about these cuffs?\"");
                break;
            case "key":
                say("\"I don't know where the key is.\"");
                break;
            default:
                say("\"Could we talk about that after you get me out of these cuffs?\"");
                break;
        }
    } else {
        switch (x) {    
            case "self":
                say("\"Me? I'm fine. Thanks for asking, buddy.\"");
                break;
            case "sugar":
                say("\"Sorry, I haven't got any more for you. The store was all sold out.\"");
                break;
            case "adrian":
                say("\"I don't know, he seems like a nice guy, doesn't he?\"");
                break;
            case "laurie":
                say("\"Oh, uh, she's at the Rockefeller Center. With Dr. Manhattan.\"");
                break;
            case "gun":
                say("\"Is it still working all right?\"");
                break;
            case "leslie":
                say("\"She's long gone.\"");
                break;
            case "archie":
                say("\"Archie? I start him up now and then just to make sure everything's still working. I don't really know why...\"");
                break;
        }
    }
}
function giveDanGun() {
    if (gs("danfree") == 0) {
        say("\"Rorschach, in case you hadn't noticed, I'm [ihandcuffed to my bed.i]\"");
        return;
    } else if (charloc(dan) == danshouse2) {
        say("\"Hang on, I'll be down in a minute.\"");
        return;
    } else if (thingmod(grappling_gun) > 0) {
        say("\"What, you broke it [iagain?i] No...it looks all right to me. Why don't you go try it out? Be careful!\"");
        return;
    }
    
    say("\"Wow, it's really mashed up, what did you do? Actually, you know what, I don't even want to know. Let's see...well, it's not beyond repair. Leave it with me, I'll try fixing it down in the Nest.\"\n\nDaniel takes the gun, then unlocks the basement door and goes downstairs.");
    set_thingmod(grappling_gun, 1);
    set_thingloc(grappling_gun, nowhere);
    sgs("I_" + grappling_gun.id, 0);
    set_charloc(dan, nest);
    set_talkindex(dan, 4);
    x_danshouse1();
}

makeChar(
// name, proper name, initial location:
"jon", "Dr. Manhattan", rockefeller2,
// description:
"America's superman is bright blue, implausibly well built, and naked. \
Undoubtedly there is some connection between his nudity and the licentiousness of modern \
society.  You wish he would put some clothes on.",
// generic talks:
"\"Hello Rorschach.\"",
// subjects:
"laurie::\"You continue to upset Laurie, and I will be obliged to relocate \
you to somewhere significantly less welcoming.\"\
/eddie::\"I know the Comedian's current location, but I do not tell you.\"\
/unknown::\"I have no particular hypotheses on that matter.\"",
// reactions:
"",
// presents:
"",
// mannerisms:
""
);

makeChar(
// name, proper name, initial location:
"laurie", "Miss Juspeczyk", rockefeller2,
// description:
"Laurel Jane Juspeczyk, formerly Silk Spectre II, is Dr. Manhattan's self-appointed \
concubine.  She is a shameless, abrasive, chain-smoking brat.",
// generic talks:
"[[talk_laurie()]]",
// subjects:
"jon::\"He's busy, okay? Feeling up quarks or some shit. Whatever it is, it's \
very important, and you smell like a dumpster full of dead cats, so scram.\"\
/sally::\"Don't talk about my mother, you little creep.\"\
/pingpong::\"I'll play when I'm bored, but there's no one left to beat in this place.\"\
/sugar::\"Good thing Jon can synthesize it, otherwise my coffee would taste like ass.\"\
/dan::\"He's a sweetheart. I don't know why he ever put up with you.\"\
/adrian::\"He seems kinda fake. Cute cat, though.\"\
/unknown::\"Whatever, Rorschach. Why don't you go harass somebody else?\"",
// reactions:
"",
// presents:
"",
// mannerisms:
""
); 

makeChar("bubastis", "Bubastis", nowhere,
"Veidt's pet cat is a lab-grown monstrosity, the size of a tiger, with purple fur and long tufted ears.",
"\"Mrr?\"",
"unknown::The cat blinks at you, then attends to cleaning its face.",
"",
"laser_pointer::[[giveBubuLaser()]]",
""
);
function talk_bubu()
{
    // need state flags for sitting in front of window and pinned
}
function giveBubuLaser()
{
    if (rawc.indexOf("show") == 0)
        bubuLaser();
    else
        say("Bubastis isn't interested.");
}

makeChar("adrian", "Veidt", nowhere,
"Veidt is immaculately dressed and blandly handsome.",
"Please don't break anything else in my office, Rorschach.",
"bubastis::She can get a bit rambunctious.",
"",
"",
""
);

function chars_loaded()
{	var HTMLOut = document.getElementById("outDiv").innerHTML;

	HTMLOut += "chars loaded: " + NUM_CHAR + "<br>";
	document.getElementById('outDiv').innerHTML = HTMLOut;
	
	document.getElementById('textIn').focus();
}